home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Ahoy 1988 September
/
Ahoy_Magazine_88-09_1988_Double_L.d64
/
Cryptic Product
(
.txt
)
< prev
next >
Wrap
Commodore BASIC
|
2022-10-26
|
943b
|
39 lines
0 poke53281,0:poke53280,1:print"[147] cryptic product":print"please wait..."
1 rem =================================
2 rem commodares problem #51-4 :
3 rem cryptic product
4 rem solution by
5 rem justin smalley
6 rem =================================
10 a=0:c=2
15 :
20 a=a+1:ifa=cthen20
21 b=-1:ifa>9thenend
30 b=b+1:ifb=aorb=cthen30
31 d=0:ifb>9then20
40 d=d+1:ifd=aord=bord=cthen40
41 e=-1:ifd>9then30
50 e=e+1:ife=aore=bore=core=dthen50
51 ife>9then40
55 :
60 p=(a*10+b)*10+c:q=d*10+e:r=p*q
61 r$=str$(r):iflen(r$)<6then50
65 :
70 forn=1to5:y=val(mid$(r$,n+1,1))
71 ify=aory=bory=cory=dory=ethen50
73 form=1ton-1:ifm<>nthenify=f(m)then50
74 next:f(n)=y:next
75 :
80 printp;"*";q;"=";r:end
85 :
100 rem --- to find all solutions,
110 rem ***change these lines:
120 rem 20 a=a+1
130 rem 30 b=b+1: if b=a then 30
140 rem 31 c=-1: if b>9 then 20
150 rem 41 e=-1: if d>9 then 36
160 rem 80 print p;"*";q;"=";r: goto 50
170 rem ***add these lines:
180 rem 36 c=c+1: if c=a or c=b then 36
190 rem 37 d=0: if c>9 then 30